package com.sms.project;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;

public class DelReportServlet extends HttpServlet {
	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		doGet(request, response);
	}

	@Override
	protected void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		response.setContentType("text/html;charset=utf-8");
		response.setCharacterEncoding("utf-8");
		request.setCharacterEncoding("utf-8");
		PrintWriter out = response.getWriter();
		
		String msg = "";
		String delid = request.getParameter("delid");
		if (delid != null & !delid.trim().equals("")) {
			boolean isSuccess = Task.delReport(delid);//is delete success?
			if(isSuccess) {
				msg = "ok";
			} else {
				msg = "error";
			}
		} else {
			msg = "error";
		}
		
		msg = msg.replace("/rn/g", "");//去掉产生的换行
		out.write(msg);
		out.flush();
		out.close();
	}
	
}
